package com.chen.wow.day04.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chen.wow.day04.mvc.MyTestException;

/**
 *文件上传
 *@author：email: <a href="cyb@ewppay.com"> Administrator </a> 
 *@Date 2017-4-26 下午3:13:57 
 */

@Controller
@RequestMapping("/file")
public class FileUploadController {

	@RequestMapping("/index")
	public String index(){
		throw new MyTestException();
		//return "file";
	}
	
	@RequestMapping("/upload")
	@ResponseBody
	public String upload(@RequestPart("pic") byte[] pic){
		System.out.println("upload...");
		return "success";
	}
	
	/**
	 * 
	 * @Description:路径参数
	 * @param @param title
	 * @param @return   
	 * @return String  
	 * @throws
	 * @author cyb
	 * @date 2017-4-26
	 */
	@RequestMapping("/show/{title}")
	public String show(@PathVariable("title") String title){
		System.out.println("传过来的title=" + title);
		return "file";
	}
	
	@RequestMapping("/flash")
	public String flash(Model model){
		System.out.println(model.containsAttribute("user"));
		return "flash";
	}
}
